package pers.cz.service.impl;

import pers.cz.business.PublicTemplateBusiness;
import pers.cz.model.AutoPublicTemplate;
import pers.cz.pub.BeanHelper;
import pers.cz.service.PublicTemplateService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 公共模板管理
 * @program: PostGirl-panent
 * @description: PublicTemplateImpl
 * @author: Cheng Zhi
 * @create: 2021-11-08 20:46
 **/
@Service
public class PublicTemplateServiceImpl implements PublicTemplateService {

    @Autowired
    BeanHelper beanHelper;

    @Override
    public List<AutoPublicTemplate> selectAllTemplateByPage(Integer pageStart, Integer pageLimit) {
        PublicTemplateBusiness business = new PublicTemplateBusiness();
        business.setMapper(beanHelper);
        return business.queryAllPublicTemplateByPage(pageStart, pageLimit);
    }

    @Override
    public Integer addTemplate(AutoPublicTemplate autoPublicTemplate) {
        PublicTemplateBusiness business = new PublicTemplateBusiness();
        business.setMapper(beanHelper);
        return business.addTemplate(autoPublicTemplate);
    }

    @Override
    public Integer deleteTemplate(Integer id) {
        PublicTemplateBusiness business = new PublicTemplateBusiness();
        business.setMapper(beanHelper);
        return business.deleteTemplate(id);
    }

    @Override
    public Integer selectCountTemplate() {
        PublicTemplateBusiness business = new PublicTemplateBusiness();
        business.setMapper(beanHelper);
        return business.queryCountPublicTemplate();
    }

    @Override
    public Integer updateTemplate(AutoPublicTemplate autoPublicTemplate) {
        PublicTemplateBusiness business = new PublicTemplateBusiness();
        business.setMapper(beanHelper);
        return business.updateTemplate(autoPublicTemplate);
    }

    @Override
    public List<AutoPublicTemplate> queryAllPublicTemplateName() {
        PublicTemplateBusiness business = new PublicTemplateBusiness();
        business.setMapper(beanHelper);
        return business.queryPublicTemplateName();
    }

    @Override
    public List<AutoPublicTemplate> selectPublicTemplateByNameOrId(String templateName, Integer id) {
        PublicTemplateBusiness business = new PublicTemplateBusiness();
        business.setMapper(beanHelper);
        return business.selectPublicTemplateByNameOrId(templateName, id);
    }

    @Override
    public List<String> selectParamsById(Integer id) {
        PublicTemplateBusiness business = new PublicTemplateBusiness();
        business.setMapper(beanHelper);

        return business.selectParamsById(id);
    }
}
